<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<table border="2" cellspacing="0" cellpadding="10px" id='table_id'>
			<tr>
				<th></th>
				<th>姓名</th>
				<th>年龄</th>
				<th>性别</th>
				<th>家庭住址</th>
			</tr>
			<tr>
				<td><input type="checkbox" name="girl_name" id="" value="" /></td>
				<td>李知恩</td>
				<td>22</td>
				<td>女</td>
				<td>云南省</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="man_name" id="" value="" /></td>
				<td>胡歌</td>
				<td>22</td>
				<td>男</td>
				<td>山东省</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="girl_name" id="" value="" /></td>
				<td>刘亦菲</td>
				<td>18</td>
				<td>女</td>
				<td>四川省</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="man_name" id="" value="" /></td>
				<td>彭于晏</td>
				<td>21</td>
				<td>男</td>
				<td>西藏省</td>
			</tr>
		</table>
		<br />
		<button type="button" name="button1_name" onclick="check_yes();">全选</button>
		<button type="button" name="button1_name" onclick="check_man();">全选男</button>
		<button type="button" name="button1_name" onclick="check_girl();">全选女	</button>
		<button type="button" name="button2_name" onclick="check_no();">取消全选</button>
	</body>
	<script type="text/javascript">
		function check_man(){
			var man_var = document.getElementsByName('man_name');
			for(var i=0;i<man_var.length;i++){
				man_var[i].checked=true;
			}
		}
		function check_girl(){
			var man_var = document.getElementsByName('girl_name');
			for(var i=0;i<man_var.length;i++){
				man_var[i].checked=true;
			}
		}
		function check_yes(){
			var table_var = document.getElementById('table_id');
			var input_var = document.getElementsByTagName('input');
			for(var i=0; i<input_var.length; i++){
				input_var[i].checked=true;
			}
		}
		function check_no(){
			var table_var = document.getElementById('table_id');
			var input_var = document.getElementsByTagName('input');
			for(var i=0; i<input_var.length; i++){
				input_var[i].checked=false;
			}
		}
	</script>
</html>